<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>睿途题库 - 登录</title>
    <script src="assets/js/tailwind.min.js"></script>
    <link href="assets/css/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/remixicon.min.css" rel="stylesheet">
    
    <!-- Tailwind 配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#4080FF',
                        accent: '#00B42A',
                        dark: '#1D2129',
                        light: '#F2F3F5',
                        muted: '#86909C'
                    },
                    fontFamily: {
                        inter: ['Inter', 'system-ui', 'sans-serif'],
                    },
                    boxShadow: {
                        'card': '0 10px 30px -5px rgba(0, 0, 0, 0.1)',
                    }
                },
            }
        };
    </script>
    
    <!-- 自定义样式 -->
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .bg-pattern {
                background-image: 
                    radial-gradient(circle at 10% 20%, rgba(22, 93, 255, 0.05) 0%, transparent 20%),
                    radial-gradient(circle at 80% 30%, rgba(64, 128, 255, 0.05) 0%, transparent 25%),
                    radial-gradient(circle at 40% 70%, rgba(0, 180, 42, 0.05) 0%, transparent 30%),
                    radial-gradient(circle at 90% 90%, rgba(22, 93, 255, 0.05) 0%, transparent 20%);
            }
            .animate-float {
                animation: float 6s ease-in-out infinite;
            }
            @keyframes float {
                0% { transform: translateY(0px); }
                50% { transform: translateY(-15px); }
                100% { transform: translateY(0px); }
            }
            .captcha-refresh {
                transition: transform 0.3s ease;
            }
            .captcha-refresh:hover {
                transform: rotate(90deg);
            }
            .education-bg {
                background-image: 
                    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><defs><pattern id="pattern-circles" x="0" y="0" width="50" height="50" patternUnits="userSpaceOnUse" patternContentUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(22, 93, 255, 0.1)"></circle></pattern></defs><rect x="0" y="0" width="100%" height="100%" fill="url(%23pattern-circles)"></rect><path d="M0,150 Q250,250 500,150 T1000,150" stroke="rgba(64, 128, 255, 0.15)" stroke-width="2" fill="none"></path><path d="M0,250 Q250,150 500,250 T1000,250" stroke="rgba(0, 180, 42, 0.1)" stroke-width="2" fill="none"></path><path d="M0,350 Q250,450 500,350 T1000,350" stroke="rgba(22, 93, 255, 0.1)" stroke-width="2" fill="none"></path><circle cx="150" cy="150" r="30" fill="rgba(22, 93, 255, 0.05)"></circle><circle cx="850" cy="250" r="40" fill="rgba(0, 180, 42, 0.05)"></circle><circle cx="450" cy="350" r="25" fill="rgba(64, 128, 255, 0.05)"></circle><g transform="translate(50, 80)"><path d="M0,0 L20,0 L20,30 L0,30 Z M5,5 L15,5 L15,25 L5,25 Z" fill="rgba(22, 93, 255, 0.05)" /></g><g transform="translate(250, 120)"><path d="M5,0 L15,0 L15,30 L5,30 Z M5,15 L20,15 L15,30 L5,30 Z" fill="rgba(0, 180, 42, 0.05)" /></g><g transform="translate(750, 90)"><path d="M0,10 L15,0 L30,10 L15,20 Z M5,12 L15,17 L25,12 Z" fill="rgba(64, 128, 255, 0.05)" /></g><g transform="translate(900, 320)"><circle cx="15" cy="15" r="15" fill="rgba(22, 93, 255, 0.05)" /><path d="M5,15 L25,15 M15,5 L15,25" stroke="rgba(22, 93, 255, 0.1)" stroke-width="2" /></g><g transform="translate(400, 280)"><path d="M0,0 L30,0 L30,20 L20,20 L20,30 L10,30 L10,20 L0,20 Z" fill="rgba(0, 180, 42, 0.05)" /></g><g transform="translate(650, 380)"><path d="M5,0 L25,0 L25,30 L5,30 Z M5,10 L25,10 M5,20 L25,20" fill="none" stroke="rgba(64, 128, 255, 0.05)" stroke-width="2" /></g></svg>');
            }
            .tab-active {
                color: #165DFF;
                border-color: #165DFF;
            }
        }
    </style>
</head>
<body class="font-inter bg-gray-50 min-h-screen flex flex-col items-center justify-center education-bg relative pb-20">
    <!-- 背景装饰元素 -->
    <div class="absolute inset-0 overflow-hidden -z-10">
        <div class="absolute top-10 left-10 w-40 h-40 rounded-full bg-primary/10 animate-float">
            <div class="w-full h-full flex items-center justify-center text-primary/20 text-6xl">
                <i class="ri-book-2-line"></i>
            </div>
        </div>
        <div class="absolute bottom-20 right-20 w-60 h-60 rounded-full bg-secondary/10 animate-float" style="animation-delay: -2s">
            <div class="w-full h-full flex items-center justify-center text-secondary/20 text-7xl">
                <i class="ri-graduation-cap-line"></i>
            </div>
        </div>
        <div class="absolute top-1/3 right-1/4 w-32 h-32 rounded-full bg-accent/10 animate-float" style="animation-delay: -4s">
            <div class="w-full h-full flex items-center justify-center text-accent/20 text-5xl">
                <i class="ri-lightbulb-line"></i>
            </div>
        </div>
    </div>

    <div class="mt-20">
        <!-- 登录卡片 -->
        <div class="w-full max-w-md px-6 py-8 bg-white rounded-2xl shadow-card relative overflow-hidden">
            <!-- 顶部装饰条 -->
            <div class="absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-primary to-accent"></div>
            
            <!-- 标题区域 -->
            <div class="text-center mb-6">
                <h1 class="text-[clamp(1.5rem,3vw,2rem)] font-bold text-dark">睿途题库-登录</h1>
                <p class="text-muted mt-2">欢迎回来，请登录您的账号</p>
            </div>
            
            <!-- 登录选项卡 -->
            <div class="flex border-b mb-6">
                <button id="tab-account" class="tab-active flex-1 py-2 text-center font-medium border-b-2 border-transparent transition-colors">
                    <i class="ri-user-3-line mr-1"></i> 用户名/邮箱
                </button>
                <button id="tab-phone" class="flex-1 py-2 text-center font-medium border-b-2 border-transparent text-muted transition-colors">
                    <i class="ri-smartphone-line mr-1"></i> 手机号
                </button>
            </div>
            
            <!-- 登录表单 -->
            <form id="loginForm" class="space-y-5">
                <!-- 用户名/邮箱登录表单 -->
                <div id="form-account" class="space-y-5">
                    <!-- 用户名/邮箱 -->
                    <div class="space-y-2">
                        <label for="email" class="block text-sm font-medium text-dark">用户名/邮箱</label>
                        <div class="relative">
                            <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                                <i class="ri-user-line"></i>
                            </span>
                            <input type="text" id="email" name="email" 
                                   class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                                   placeholder="请输入用户名或邮箱">
                        </div>
                    </div>
                    
                    <!-- 密码 -->
                    <div class="space-y-2">
                        <label for="password" class="block text-sm font-medium text-dark">密码</label>
                        <div class="relative">
                            <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                                <i class="ri-lock-line"></i>
                            </span>
                            <input type="password" id="password" name="password" 
                                   class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                                   placeholder="请输入密码">
                            <button type="button" id="togglePassword" class="absolute inset-y-0 right-0 flex items-center pr-3 text-muted hover:text-primary transition-colors">
                                <i class="ri-eye-off-line"></i>
                            </button>
                        </div>
                    </div>
                    
                    <!-- 验证码 -->
                    <div class="space-y-2">
                        <label for="captcha" class="block text-sm font-medium text-dark">验证码</label>
                        <div class="flex space-x-3">
                            <div class="relative flex-1">
                                <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                                    <i class="ri-shield-line"></i>
                                </span>
                                <input type="text" id="captcha" name="captcha" 
                                       class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                                       placeholder="请输入验证码">
                            </div>
                            <div class="flex items-center">
                                <div id="captchaImage" class="w-36 h-12 bg-gray-100 rounded-lg flex items-center justify-center text-dark font-bold tracking-wider select-none">
                                    <!-- Captcha will be generated by JavaScript -->
                                </div>
                                <button type="button" id="refreshCaptcha" class="ml-2 text-muted hover:text-primary transition-colors captcha-refresh">
                                    <i class="ri-refresh-line"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 手机号登录表单 -->
                <div id="form-phone" class="space-y-5 hidden">
                    <!-- 手机号 -->
                    <div class="space-y-2">
                        <label for="phone" class="block text-sm font-medium text-dark">手机号</label>
                        <div class="relative">
                            <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                                <i class="ri-smartphone-line"></i>
                            </span>
                            <input type="tel" id="phone" name="phone" 
                                   class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                                   placeholder="请输入手机号">
                        </div>
                    </div>
                    
                    <!-- 短信验证码 -->
                    <div class="space-y-2">
                        <label for="smsCode" class="block text-sm font-medium text-dark">短信验证码</label>
                        <div class="flex space-x-3">
                            <div class="relative flex-1">
                                <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                                    <i class="ri-mail-line"></i>
                                </span>
                                <input type="text" id="smsCode" name="smsCode" 
                                       class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                                       placeholder="请输入验证码">
                            </div>
                            <button type="button" id="sendSmsCode" class="min-w-[120px] py-3 px-4 bg-primary/10 text-primary font-medium rounded-lg hover:bg-primary/20 transition-colors whitespace-nowrap">
                                获取验证码
                            </button>
                        </div>
                    </div>
                </div>
                
                <!-- 登录按钮 -->
                <button type="submit" class="w-full py-3 bg-primary hover:bg-primary/90 text-white font-medium rounded-lg transition-all duration-200 transform hover:-translate-y-1 hover:shadow-lg flex items-center justify-center">
                    <span>登录</span>
                    <i class="ri-login-box-line ml-2"></i>
                </button>
                
                <!-- 其他选项 -->
                <div class="flex items-center justify-between text-sm">
                    <div class="flex items-center">
                        <input type="checkbox" id="remember" name="remember" class="w-4 h-4 border border-gray-300 rounded focus:ring-primary/30 focus:ring-offset-0 text-primary">
                        <label for="remember" class="ml-2 text-muted">记住我</label>
                    </div>
                    <a href="changePassword.html" class="text-primary hover:underline">忘记密码？</a>
                </div>
                
                <!-- 其他登录方式 -->
                <div class="relative mt-6">
                    <button type="button" id="toggleOtherLogin" class="w-full text-center text-sm text-muted hover:text-primary transition-colors flex items-center justify-center">
                        <span>其他登录方式</span>
                        <i class="ri-arrow-down-s-line ml-1 transition-transform duration-300"></i>
                    </button>
                </div>
                
                <div id="otherLoginMethods" class="mt-6 grid grid-cols-3 gap-3 hidden transform transition-all duration-300 opacity-0">
                    <button type="button" class="flex flex-col justify-center items-center px-4 py-3 border border-gray-200 rounded-lg shadow-sm bg-white text-sm font-medium text-muted hover:bg-gray-50 hover:border-primary/20 transition-all">
                        <i class="ri-wechat-line text-[#07C160] text-2xl mb-1"></i>
                        <span class="text-xs">微信</span>
                    </button>
                    <button type="button" class="flex flex-col justify-center items-center px-4 py-3 border border-gray-200 rounded-lg shadow-sm bg-white text-sm font-medium text-muted hover:bg-gray-50 hover:border-primary/20 transition-all">
                        <i class="ri-qq-line text-[#1DA1F2] text-2xl mb-1"></i>
                        <span class="text-xs">QQ</span>
                    </button>
                    <button type="button" class="flex flex-col justify-center items-center px-4 py-3 border border-gray-200 rounded-lg shadow-sm bg-white text-sm font-medium text-muted hover:bg-gray-50 hover:border-primary/20 transition-all">
                        <i class="ri-alipay-line text-[#1677FF] text-2xl mb-1"></i>
                        <span class="text-xs">支付宝</span>
                    </button>
                </div>
                
                <!-- 注册链接 -->
                <div class="text-center text-sm mt-6">
                    <span class="text-muted">还没有账号？</span>
                    <a href="register.html" class="text-primary hover:underline">立即注册</a>
                </div>
            </form>
        </div>
    </div>

    <!-- 页脚 -->
    <div id="copyright" class="w-full text-center text-sm text-muted py-6 absolute bottom-0 left-0 right-0 transition-all duration-300 bg-white/50 backdrop-blur-sm">
        <p>© 2023 睿途题库. 保留所有权利.</p>
    </div>

    <!-- JavaScript -->
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 获取DOM元素
            const tabAccount = document.getElementById('tab-account');
            const tabPhone = document.getElementById('tab-phone');
            const formAccount = document.getElementById('form-account');
            const formPhone = document.getElementById('form-phone');
            const togglePassword = document.getElementById('togglePassword');
            const passwordInput = document.getElementById('password');
            const refreshCaptcha = document.getElementById('refreshCaptcha');
            const captchaImage = document.getElementById('captchaImage');
            const sendSmsCode = document.getElementById('sendSmsCode');
            const toggleOtherLogin = document.getElementById('toggleOtherLogin');
            const otherLoginMethods = document.getElementById('otherLoginMethods');
            
            // 切换登录方式
            tabAccount.addEventListener('click', function() {
                this.classList.add('tab-active');
                tabPhone.classList.remove('tab-active');
                formAccount.classList.remove('hidden');
                formPhone.classList.add('hidden');
            });
            
            tabPhone.addEventListener('click', function() {
                this.classList.add('tab-active');
                tabAccount.classList.remove('tab-active');
                formPhone.classList.remove('hidden');
                formAccount.classList.add('hidden');
            });
            
            // 切换密码显示/隐藏
            togglePassword.addEventListener('click', function() {
                const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
                passwordInput.setAttribute('type', type);
                this.querySelector('i').classList.toggle('ri-eye-off-line');
                this.querySelector('i').classList.toggle('ri-eye-line');
            });
            
            // 刷新验证码
            refreshCaptcha.addEventListener('click', function() {
                // 这里添加刷新验证码的逻辑
                this.classList.add('animate-spin');
                setTimeout(() => {
                    this.classList.remove('animate-spin');
                }, 500);
            });
            
            // 发送短信验证码
            let countdown = 60;
            let timer = null;
            
            sendSmsCode.addEventListener('click', function() {
                if (!this.classList.contains('disabled')) {
                    this.classList.add('disabled', 'opacity-50', 'cursor-not-allowed');
                    this.textContent = countdown + 's后重新发送';
                    
                    timer = setInterval(() => {
                        countdown--;
                        this.textContent = countdown + 's后重新发送';
                        
                        if (countdown <= 0) {
                            clearInterval(timer);
                            this.classList.remove('disabled', 'opacity-50', 'cursor-not-allowed');
                            this.textContent = '获取验证码';
                            countdown = 60;
                        }
                    }, 1000);
                }
            });

            // 切换其他登录方式的显示/隐藏
            let isOtherLoginVisible = false;
            const copyright = document.getElementById('copyright');
            
            toggleOtherLogin.addEventListener('click', function() {
                isOtherLoginVisible = !isOtherLoginVisible;
                const arrowIcon = this.querySelector('i');
                
                if (isOtherLoginVisible) {
                    otherLoginMethods.classList.remove('hidden');
                    // 使用setTimeout确保在显示后再添加opacity，以触发过渡效果
                    setTimeout(() => {
                        otherLoginMethods.classList.remove('opacity-0');
                        arrowIcon.style.transform = 'rotate(180deg)';
                    }, 0);
                } else {
                    otherLoginMethods.classList.add('opacity-0');
                    arrowIcon.style.transform = 'rotate(0deg)';
                    // 等待过渡效果完成后再隐藏元素
                    setTimeout(() => {
                        otherLoginMethods.classList.add('hidden');
                    }, 300);
                }

                // 调整页面布局以确保版权信息始终在底部
                adjustLayout();
            });

            // 调整页面布局的函数
            function adjustLayout() {
                const mainContent = document.querySelector('.max-w-md');
                const otherLoginHeight = otherLoginMethods.scrollHeight;
                const windowHeight = window.innerHeight;
                const mainContentHeight = mainContent.scrollHeight;
                const totalHeight = mainContentHeight + (isOtherLoginVisible ? otherLoginHeight : 0);

                // 如果内容高度超过窗口高度，移除fixed定位
                if (totalHeight + 100 > windowHeight) {
                    document.body.classList.add('pb-20');
                    copyright.classList.add('relative');
                    copyright.classList.remove('fixed');
                } else {
                    document.body.classList.remove('pb-20');
                    copyright.classList.remove('relative');
                    copyright.classList.add('fixed', 'bottom-0');
                }
            }

            // 监听窗口大小变化
            window.addEventListener('resize', adjustLayout);
            
            // 初始调整布局
            adjustLayout();
        });
    </script>
</body>
</html>
